# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=python-rpio
pkgname=('python2-rpio' 'python-rpio')
_pkgname=RPIO
pkgver=0.10.0
pkgrel=9
epoch=1
pkgdesc='A GPIO toolbox for the Raspberry Pi.'
arch=('x86_64' 'aarch64')
url='https://pypi.org/project/rpio/#files'
license=('LGPL3')
makedepends=('python2-setuptools' 'python-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('6b366d47809e0f1b3733316821bdebd02a202cdf4a31f67fda07aa806cfcf546bd2a38644e25d481ec0d6fd2210ea697fdc0d0f3e57340ab40d81d7e275f483c')

prepare() {
  cp -a "$_pkgname-$pkgver"{,-2}
}

build() {
  cd "$_pkgname-$pkgver-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname-$pkgver"

  python setup.py build
}

package_python2-rpio() {
  depends=('python2')

  cd "$_pkgname-$pkgver-2"

  python2 setup.py install --prefix=/usr --root="$pkgdir" --optimize=1 \
    --skip-build

  for i in "$pkgdir/usr/bin/"* ; do
    mv $i "${i}2"
  done
}

package_python-rpio() {
  depends=('python')

  cd "$_pkgname-$pkgver"

  python setup.py install --prefix=/usr --root="$pkgdir" --optimize=1 \
    --skip-build
}

